var sidebar_tabs = null;

window.addEvent('domready', function(){
	if ($('sidebar_tabs'))
	{
		initSidebarTabManager();
		(function(){setupInfoSize();}).delay(600);
	}
});

function setupInfoSize()
{
	var formElement = $('form_element').getElement('div.form');
	var formSize = formElement.getSize();
	var tabElement = $('sidebar_tabs').getElement('li');
	var tabSize = tabElement.getSize();

	var tabHeight = formSize.y-23-tabSize.y;
	$('sidebar_pages').getElements('li.page').each(function(element){
		element.setStyle('height', tabHeight+'px');
	})
	
	var filesHeaderSize = $('files_header').getSize();
	var filesStatusBarSize = $('file_browser_statusbar').getSize();
	var filesControlsBarSize = $('file_browser_controls').getSize();
	
	var filesDescriptionSize = $('files_description').getSize();
	$('file_browser_file_list').setStyle('height', (tabHeight-filesHeaderSize.y-filesDescriptionSize.y - 4 - filesStatusBarSize.y - filesControlsBarSize.y)+'px');
}

function initSidebarTabManager()
{
	sidebar_tabs = new TabManager('sidebar_tabs', 'sidebar_pages', {trackTab: false});
	sidebar_tabs.addEvent('onTabClick', setupInfoSize);
}

window.addEvent('phpr_editor_resized', setupInfoSize);